package com.cskaoyan.jwt;

import com.cskaoyan.jwt.utils.JwtTokenUtils;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;


@Slf4j
public class Main {

//    public static Logger logger = LoggerFactory.getLogger(Main.class);


    public static void main(String[] args) {
        main1();
//         main2();
    }



    // 加密
    public static void main1() {

//        //1. 创建对象
//        JwtTokenUtils tokenUtils = new JwtTokenUtils();
//
//        // 2.设置msg
//        tokenUtils.setMsg("张三");

        // 利用builder注解的建造者来构建对象
        JwtTokenUtils jwtTokenUtils = JwtTokenUtils.builder().msg("张三").build();


        // 3. 调用方法，生成token
        String token = jwtTokenUtils.creatJwtToken();

//        System.out.println("token:" + token);

        String.format("张三: %s  李四: %s", "100","200");

        log.info("token:{}",token);
        // eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJ3bGd6cyIsImV4cCI6MTY3MzMyMDg3MCwidXNlciI6IjcxNkM3Rjk3MDE0QzI1MkZBQjNERURBMEQzQUQ4NkVBIn0.6-CAt1fnSFWB8ZfLxnwYY-c0tTGQO-7dAnIA6QMzJyA
    }

    // 解密
    public static void main2() {
        String token = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJ3bGd6cyIsImV4cCI6MTY3MzMyMDg3MCwidXNlciI6IjcxNkM3Rjk3MDE0QzI1MkZBQjNERURBMEQzQUQ4NkVBIn0.6-CAt1fnSFWB8ZfLxnwYY-c0tTGQO-7dAnIA6QMzJyA";
        JwtTokenUtils.JwtTokenUtilsBuilder builder = JwtTokenUtils.builder().token(token);

        JwtTokenUtils utils = builder.build();

        String msg = utils.freeJwt();

        System.out.println("msg:" + msg);
//        log.info("msg1:{}",msg);

    }
}
